package com.guanyong.admin.controllers.page;

import com.guanyong.model.HistoryTodayModel;
import com.guanyong.services.HistoryTodayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by mxk on 2017/6/6.
 */
@Controller
@RequestMapping("/page/histroy")
public class HistoryPage  extends baseController{

    @RequestMapping({"/list"})
    String messageList(HttpServletRequest request) {

        return  "/histroy/list";
    }
    @Autowired
    HistoryTodayService historyTodayService;

    @RequestMapping({"/update"})
    String messageAdd(Model model, HttpServletRequest request) {
        String fid=request.getParameter("fid");
        if (fid!=null && fid!=""){
            Integer Nfid=Integer.parseInt(fid);
            HistoryTodayModel historyTodayModel=
                    historyTodayService.GetHistoryTodayModelById(Nfid);
            if (historyTodayModel!=null){
                model.addAttribute("history",historyTodayModel);
                return "/histroy/update";
            }
            else{
                return "errorPage/500";
            }
        }
        else{
            return "errorPage/500";
        }

    }

}
